fun main(arg: Array<String>) {
    println(Solution().isPalindrome(10))
}

/**
 * 0 1 0  0 1 1 0 0 1
 */
class Solution {

    fun isPalindrome(x: Int): Boolean {
        if (x < 0) return false
        if (x < 10) return true
        var n = x
        var k: Int
        val numberArray = ArrayList<Int>()
        while (n != 0) {
            k = n % 10
            n /= 10
            numberArray.add(k)
        }
        var header = 0
        var tail = numberArray.size - 1
        while (header < tail) {
            if (numberArray[header] != numberArray[tail])
                return false
            header++
            tail--
        }
        return true
    }
}